Fix uninitialized digest_len field, causing WebSocket handshake to g_assert.
authorC. Scott Ananian <cscott@cscott.net>
Fri, 11 Nov 2011 21:26:12 +0000 (16:26 -0500)
committerAlexander Larsson <alexl@redhat.com>
Mon, 14 Nov 2011 08:55:19 +0000 (09:55 +0100)
g_checksum_get_digest checks to ensure that the passed digest_len is long
enough to hold the digest, before setting it to the actual length of the
digest returned.  Digest_len is uninitialized in the code, so if you're
lucky it will be larger than 20 and everything will work fine.  If you're
unlucky, g_checksum_get_digest will return either -1 or some number less
than 20, and the g_assert(digest_len==20) will fail.

gdk/broadway/gdkdisplay-broadway.c

index 87fc1c87b328c74be1b1c0a39ff5dee4162aa69b..5c711b7ea2c7a2d5e4ea4a936e521b0da6c0b09e 100644 (file)
@@ -660,8 +660,8 @@ send_error (HttpRequest *request,
 static gchar *
 generate_handshake_response_wsietf_v7 (const gchar *key)
 {
-  guchar digest[20];
-  gsize digest_len;
+  gsize digest_len = 20;
+  guchar digest[digest_len];
   GChecksum *checksum;
 
   checksum = g_checksum_new (G_CHECKSUM_SHA1);